// checksum.h: interface for the checksum class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_CHECKSUM_H__95BC619C_FCD6_4C75_9DEF_84249A25AE11__INCLUDED_)
#define AFX_CHECKSUM_H__95BC619C_FCD6_4C75_9DEF_84249A25AE11__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

// A Checksum Algorithm by Joseph M. Newcomer
// Ref: "http://www.pgh.net/~newcomer/checksum.htm"

class checksum	
{
public:
	checksum() { clear(); }
	void clear() { sum = 0; r = 55665; c1 = 52845; c2 = 22719;}
	void add(DWORD w);
	void add(BOOL w) { add((DWORD)w); }
	void add(UINT w) { add((DWORD)w); }
	void add(WORD w);
	void add(const CString & s);
	void add(LPBYTE b, UINT length);
	void add(BYTE b);
	void add(const CTime & time);
	void add(float d) { add((double)d); }
	void add(double d);
	DWORD get() { return sum; }
protected:
	WORD r;
	WORD c1;
	WORD c2;
	DWORD sum;
};

#endif // !defined(AFX_CHECKSUM_H__95BC619C_FCD6_4C75_9DEF_84249A25AE11__INCLUDED_)
